home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cbibcode.arc
/
REGBGIFT.C
< prev
next >
Wrap
Text File
|
1991-08-05
|
2KB
|
53 lines
/* regbgift.c---registerfarbgifont.c, pg 851-853 */
/* Example that loads a font file into memory and uses
registerfarbgifont to register and use it. */
#include <graphics.h>
#include <io.h>
#include <fcntl.h>
#include <alloc.h>
#include <stdio.h>
main()
{
void * sserif_fontp; /* Pointer to font buffer */
int fhandle, graphdriver = DETECT, graphmode, errorcode;
unsigned fontsize;
if ((fhandle = open("c:\\tc\\sans.chr", O_RDONLY|O_BINARY)) == -1)
{
printf("unable to open font file 'SANS.CHR'\n");
exit (1);
}
fontsize = filelength(fhandle); /* find out size */
if((sserif_fontp = malloc(fontsize)) == NULL)
{
printf("Failed to allocate memory for font file "
"'SANS.CHR'\n");
exit(1);
}
if (read(fhandle, sserif_fontp, fontsize) != fontsize)
{
printf("Error reading font file 'SANS.CHR'\n");
exit(1);
}
close(fhandle); /* close font file */
if (registerfarbgifont(sserif_fontp) != SANS_SERIF_FONT)
{
printf("Error registering font file 'SANS.CHR'\n");
exit(1);
}
initgraph(&graphdriver, &graphmode, "c:\\tc");
errorcode = graphresult();
if(errorcode != grOk)
{
printf(grapherrormsg(errorcode));
exit(1);
}
settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 4);
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy( getmaxx() / 2, getmaxy() /2,
"Turbo C 2.0 Graphics: Sans Serif Font");
settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 1);
outtextxy(getmaxx()/2, getmaxy() - 50, "Press any key to exit:");
getch();
closegraph(); /* Exit graphics library */
}